package com.kakaxi.mybilibili.adapter.pager;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.kakaxi.mybilibili.base.BaseFragment;
import com.kakaxi.mybilibili.module.video.view.VideoCommentFragment;
import com.kakaxi.mybilibili.module.video.view.VideoIntroFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * 视频滑动布局适配器
 * Created by kakaxi on 16/11/20.
 */

public class VideoPagerAdapter extends FragmentPagerAdapter {

    private String[] mTitleArray = {
            "简介", "评论"
    };

    private List<BaseFragment> mFragmentArray;

    public VideoPagerAdapter(FragmentManager fm, String aid) {
        super(fm);
        mFragmentArray = new ArrayList<>();
        mFragmentArray.add(VideoIntroFragment.newInstance());
        mFragmentArray.add(VideoCommentFragment.newInstance(aid));
    }

    @Override
    public Fragment getItem(int position) {
        return mFragmentArray.get(position);
    }

    @Override
    public int getCount() {
        return mTitleArray.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitleArray[position];
    }
}
